<?php

$file = fopen("china_h.txt", "r") or exit("Unable to open file!");

$yb = '';
$sheng = '';
$shi = '';
$qu = '';
while(!feof($file))
{
    $line = trim(fgets($file));
    if (substr_count($line," ") == 0){
        $arr = explode("	",$line);
        if(count($arr) == 2){
            $yb = trim($arr[0]);
            $sheng = trim($arr[1]);
            $shi = "";
            $qu = "";
        }
    }
    if (substr_count($line," ") == 1){
        $arr = explode("	",$line);
        if(count($arr) == 2){
            $yb = trim($arr[0]);
            $shi = trim($arr[1]);
            $qu = "";
        }
    }
    if (substr_count($line," ") == 3){
        $arr = explode("	",$line);
        if(count($arr) == 2){
            $yb = trim($arr[0]);
            $qu = trim($arr[1]);
        }
    }
    $out = $yb." ".$sheng." ".$shi." ".$qu;
    echo trim($out)."\n";
}
fclose($file);